﻿using System.Drawing;

namespace ZhCAD
{
    public class MyCommon
    {
        public static Image Createimg(Color layerColor, Size size, bool isrec)
        {
            Image img = new Bitmap(size.Width, size.Height);
            var g = Graphics.FromImage(img);
            var rec = new Rectangle(Point.Empty, size);
            if (!isrec)
            {
                g.TranslateTransform(size.Width / 2, size.Height / 2);
                g.RotateTransform(45);
                rec = new Rectangle(0, 0, size.Width, size.Height);
                rec.Offset(-rec.Width / 2, -rec.Height / 2);
                rec.Inflate(-1, -1);
            }
            rec.Offset(-1, -1);
            rec.Inflate(-2, -2);
            g.DrawRectangle(Pens.Black, rec);
            rec.Offset(1, 1);
            rec.Width -= 1;
            rec.Height -= 1;
            Brush mbrush = new SolidBrush(layerColor);
            g.FillRectangle(mbrush, rec);
            g.Dispose();
            return img;
        }
    }
}